package core.manager.battle
{
	import core.Language;
	
	import mapengine.effects.EffectFactory;
	
	import values.avatar.IAvatarValue;
	import values.skill.SkillValue;

	public class BattleEffectManager
	{
		/**
		 * 显示技能特效 
		 * @param skillValue
		 * @param A
		 * @param B
		 * 
		 */		
		public static function showSkillEffect(skillValue:SkillValue , A:IAvatarValue , B:IAvatarValue , randomOne:Boolean = false):void
		{
			EffectFactory.createSkillEffect(skillValue.name , skillValue.template.demo , skillValue.template.demoClassRef , B.x , B.y , B.avatar.world);
			
			if(!randomOne)
			{
				EffectFactory.createSkillEffect(skillValue.name , skillValue.template.ownerDemoPath , skillValue.template.ownerDemoClassRef , A.x , A.y , A.avatar.world);
			}
		}
		
		/**
		 * 显示攻击效果  
		 * @param A
		 * @param B
		 * @param damageObj state暴击什么的
		 * 
		 */	
		public static function showDamageEffect(A:IAvatarValue , B:IAvatarValue , damageObj:Object):void
		{
			if(damageObj.data != 0)
			{
				EffectFactory.createTextEffect(damageObj.data > 0 ? ("-" + damageObj.data) : ("+" + damageObj.data) , B.x , B.y , B.avatar.world);
			}
			for each(var str:String in damageObj.state)
			{
				switch(str)
				{
					case "suppress":
					case "crit":
						EffectFactory.createTextEffect(Language.getText( "@" + str + "_label") , A.x , A.y , A.avatar.world);
						break;
					case "dodge":
					case "block":
						EffectFactory.createTextEffect(Language.getText("@" + str + "_label") , B.x , B.y , B.avatar.world);
						break;
				}
			}
		}
		
		/**
		 * 显示效果 
		 * @param A
		 * @param B
		 * @param damageObj proName 伤害的属性名字
		 * 
		 */		
		public static function showEffectValue(A:IAvatarValue , B:IAvatarValue , damageObj:Object):void
		{
			if(damageObj.proName != "hp" && damageObj.proName != "mp") return;
			
			EffectFactory.createTextEffect(damageObj.num > 0 ? ("-" + damageObj.num) : ("+" + damageObj.num) , B.x , B.y , B.avatar.world);
		}
	}
}